package com.naicheng.ivote.adapter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.naicheng.ivote.R;
import com.naicheng.ivote.doman.HotCommentListBean;
import com.naicheng.ivote.doman.HotCommentsChildBean;
import com.naicheng.ivote.doman.HotOptionsBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CommentChildListAdapter extends BaseAdapter {

    private Context context;
	private LayoutInflater mInflater;
    private ArrayList<HotCommentsChildBean> list;

    /**
     * 
     * @param context
     * @param list
     */
    public CommentChildListAdapter(Context context,ArrayList<HotCommentsChildBean> list)
    {
    	this.context=context;
    	this.list = list;
    	this.mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }


    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
    	ViewHolder	holder;
    	if(convertView == null){
    		holder = new ViewHolder();
    		convertView = mInflater.inflate(R.layout.hotdetail_comment_child_item, null);
    		holder.hotdetail_comment_child_type = (TextView) convertView.findViewById(R.id.hotdetail_comment_child_type);
    		holder.hotdetail_comment_child_text = (TextView) convertView.findViewById(R.id.hotdetail_comment_child_text);
    		
    		convertView.setTag(holder);
    		convertView.setId(position);
    	}else{
    		holder = (ViewHolder) convertView.getTag();
    	}
    	holder.hotdetail_comment_child_text.setText(list.get(position).getText());
    	if(2==list.get(position).getType()){
    		holder.hotdetail_comment_child_type.setText("题主回:");
    		holder.hotdetail_comment_child_type.setTextColor(context.getResources().getColor(R.color.hotdetail_child_type));
		}else{
			holder.hotdetail_comment_child_type.setText("回题主:");
    		holder.hotdetail_comment_child_type.setTextColor(context.getResources().getColor(R.color.bai1));
		}
    	
    	holder.hotdetail_comment_child_text.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				System.out.println("子评论啊啊啊啊啊"+position);
			}
		});
        return convertView;
    }

    public class ViewHolder
    {
    	public TextView hotdetail_comment_child_type;
    	public TextView hotdetail_comment_child_text;
    	
    }
    
}
